<?php

namespace App\Services\Article;

use App\Services\Article\Article\ArticleclassifyLogic;
use App\Services\Article\EnterpriseArticle\EnterpriseArticleclassifyLogic;


/**
 * 文章分类服务层
 * Class ApiArticleClassify
 * @package App\Services\Article
 */
class ApiArticleClassify
{
//--------------------------------企业站前台开始------------------------------------------
    /**
     * 文章分类列表
     */
    public function articleClass($data)
    {
        return (new EnterpriseArticleclassifyLogic())->articleClass($data);
    }

    /**
     * 指定文章分类
     */
    public function assignClass($data)
    {
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $data = init_array($data,['pid'=>""]);
        ValidateArticle::checkValidate($data,['pid']);
        return (new EnterpriseArticleclassifyLogic())->assignClass($data);
    }
//--------------------------------企业站前台结束------------------------------------------


    /**
     * 添加文章分类
     */
    public function add($data)
    {
        ValidateArticleClassify::checkValidate($data, ['name', 'belong_to']);

        return (new ArticleclassifyLogic())->add($data);
    }

    /**
     * 文章分类编辑
     */
    public function edit($data)
    {
        ValidateArticleClassify::checkValidate($data, ["id", "name", "description", "belong_to"]);

        return (new ArticleclassifyLogic())->classifyEdit($data);
    }

    /**
     * 启用某文章分类
     */
    public function classifyEnable($data)
    {
        if (empty($data)) {
            return null_data($data, "参数不能为空！");
        }
        $data = init_array($data,['id'=>'', "key"=>" "]);
        ValidateArticleClassify::checkValidate($data, ['id', 'key']);

        return (new ArticleclassifyLogic())->classifyEnable($data);
    }


    /**
     * 禁用某文章分类
     */
    public function classifyDisable($data)
    {
        if (empty($data)) {
            return null_data($data, "参数不能为空！");
        }
        $data = init_array($data,['id'=>'', "key"=>" "]);
        ValidateArticleClassify::checkValidate($data, ['id', 'key']);

        return (new ArticleclassifyLogic())->classifyDisable($data);

    }

    /**
     * 文章分类删除
     */
    public function classifyDelete($data)
    {
        if (empty($data)) {
            return null_data($data, "参数不能为空！");
        }
        $data = init_array($data,['id'=>'', "key"=>" "]);
        ValidateArticleClassify::checkValidate($data, ['id', 'key']);

        return (new ArticleclassifyLogic())->classifyDelete($data);
    }

    /**
     * 获取文章全部分类列表
     * @return array
     */
    public function classifyList():array
    {
        return (new ArticleclassifyLogic())->classifyList();
    }

    /**
     * 获取APP文章全部分类列表
     * @return array
     */
    public function appClassifyList():array
    {
        return (new ArticleclassifyLogic())->appClassifyList();
    }
    /**
     * 获取文章全部分类列表 (不分页)
     * @return array
     */
    public function themeList():array
    {
        return (new ArticleclassifyLogic())->themeList();
    }

    /**
     * 获取某一类文章分类
     */
    public function classifySomeList($data)
    {
        if (empty($data)) {
            return null_data($data, "参数不能为空！");
        }
        $data = init_array($data,['id'=>'', "key"=>" "]);
        ValidateArticleClassify::checkValidate($data, ['id', 'key']);

        return (new ArticleclassifyLogic())->classifySomeList($data);
    }

    /**
     * 不同条件下文章列表获取
     */
    public function classifyCondition($data)
    {
        if (empty($data)) {
            return null_data($data, "参数不能为空！");
        }
        $data = init_array($data,['keywords'=>'','page'=>1,'listRows'=>15]);

        return (new ArticleclassifyLogic())->classifyCondition($data);
    }

    /**
     * 获取文章主题信息
     */
    public function classifyInfo($data)
    {
        ValidateArticleClassify::checkValidate($data, ['id']);

        return (new ArticleclassifyLogic())->classifyInfo($data);
    }
}
